import { cloudService } from './index'
import type { IMoment } from '@/types/food'

export const addMomentApi = (moment: IMoment): Promise<boolean> =>
  cloudService({
    url: '/food-api/moment',
    method: 'post',
    data: moment
  })

export const updateMomentApi = (id: number, moment: IMoment): Promise<boolean> =>
  cloudService({
    url: `/food-api/moment/${id}`,
    method: 'put',
    data: moment
  })

export const deleteMomentApi = (id: number): Promise<boolean> =>
  cloudService({
    url: `/food-api/moment/${id}`,
    method: 'delete'
  })

export const queryMomentListApi = (): Promise<IMoment[]> =>
  cloudService({
    url: '/food-api/moment',
    method: 'get'
  })

export const queryMomentByIdApi = (id: number): Promise<IMoment[]> =>
  cloudService({
    url: `/food-api/moment/${id}`,
    method: 'get'
  })

export const addMomentCommentApi = (id: number, content: string): Promise<boolean> =>
  cloudService({
    url: `/food-api/moment/${id}/comment`,
    method: 'post',
    params: { content }
  })

export const addMomentLikeApi = (id: number): Promise<boolean> =>
  cloudService({
    url: `/food-api/moment/${id}/like`,
    method: 'post'
  })

export const deleteMomentLikeApi = (id: number): Promise<boolean> =>
  cloudService({
    url: `/food-api/moment/${id}/like`,
    method: 'delete'
  })
